home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 3 No 046 < prev    next >
Internet Message Format  |  1997-05-06  |  84KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-046
  3. Date: Wed, 20 Jul 1994 14:41:25 +0200 (MET DST)
  4.  
  5. C.S.M.P. Digest             Wed, 20 Jul 94       Volume 3 : Issue 46
  6.  
  7. Today's Topics:
  8.  
  9.         3D Rotational examples - Help wanted
  10.         CASE Tools for Macintosh
  11.         Debugging an applet properly (AppleScript)
  12.         GWorlds vs. Offscreens
  13.         GWorlds: When to lock pixels?
  14.         How do you write TIFFs?
  15.         How to tell Energy Saver to turn the monitor on or off
  16.         Newbie Gworld questions.
  17.         Patching Trap ExitToShell using UniversalProcPtr's
  18.         Porting from Unix to Mac - Summary
  19.         Problems with Metrowerks vs. MPW 68k C calling conventions
  20.         Special #define for Univ. Hdrs?
  21.         Why does THINK C use a jump table?
  22.  
  23.  
  24.  
  25. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  26. (pottier@clipper.ens.fr).
  27.  
  28. The digest is a collection of article threads from the internet newsgroup
  29. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  30. regularly and want an archive of the discussions.  If you don't know what a
  31. newsgroup is, you probably don't have access to it.  Ask your systems
  32. administrator(s) for details.  If you don't have access to news, you may
  33. still be able to post messages to the group by using a mail server like
  34. anon.penet.fi (mail help@anon.penet.fi for more information).
  35.  
  36. Each issue of the digest contains one or more sets of articles (called
  37. threads), with each set corresponding to a 'discussion' of a particular
  38. subject.  The articles are not edited; all articles included in this digest
  39. are in their original posted form (as received by our news server at
  40. nef.ens.fr).  Article threads are not added to the digest until the last
  41. article added to the thread is at least two weeks old (this is to ensure that
  42. the thread is dead before adding it to the digest).  Article threads that
  43. consist of only one message are generally not included in the digest.
  44.  
  45. The digest is officially distributed by two means, by email and ftp.
  46.  
  47. If you want to receive the digest by mail, send email to listserv@ens.fr
  48. with no subject and one of the following commands as body:
  49.     help                        Sends you a summary of commands
  50.     subscribe csmp-digest Your Name    Adds you to the mailing list
  51.     signoff csmp-digest            Removes you from the list
  52. Once you have subscribed, you will automatically receive each new
  53. issue as it is created.
  54.  
  55. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  56. Questions related to the ftp site should be directed to
  57. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  58. digest are available there.
  59.  
  60. Also, the digests are available to WAIS users.  To search back issues
  61. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  62. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  63.  
  64.  
  65. -------------------------------------------------------
  66.  
  67. >From Malicious_Monarch@nile.com (Malicious Monarch)
  68. Subject: 3D Rotational examples - Help wanted
  69. Date: Tue,  5 Jul 94 14:39:38 MDT
  70. Organization: The Nile BBS
  71.  
  72.      I'm looking for some examples in creating simple three dimensional objects
  73. in C.  I've just started reading Michael Chen's article in issue 14 of develop,
  74. but I imagine there are some references to explain the use of the Graf3D library
  75. and perhaps even some more simplistic code to give a basic understanding of
  76. creating and drawing three dimensional objects.
  77.  
  78.      Please understand that I'm not concerned with a user interface at this
  79. point, just simple rendering code (ie making a cube and rotating it to give the
  80. illusion that it is a three dimensional object).  If someone could point toward
  81. some source code, or any literature (books, magazines, etc.) I would really
  82. really appreciate it.  Thanks...
  83.  
  84.  
  85. -Eric A. Drumbor-
  86.  
  87.      Opinions posted are of the user, not the administration.
  88.  
  89. +++++++++++++++++++++++++++
  90.  
  91. >From nick@pitt.edu ( nick.c )
  92. Date: Tue, 5 Jul 94 17:58:41 GMT
  93. Organization: University of Pittsburgh
  94.  
  95. In Article <0007E5C6.fc@nile.com>, Malicious_Monarch@nile.com (Malicious
  96. Monarch) wrote:
  97.  
  98. >     Please understand that I'm not concerned with a user interface at this
  99. >point, just simple rendering code (ie making a cube and rotating it to give the
  100. >illusion that it is a three dimensional object).  If someone could point toward
  101. >some source code, or any literature (books, magazines, etc.) I would really
  102. >really appreciate it.  Thanks...
  103.  
  104.   There is some code called "wireframeorama" (or something like that)
  105.     that's at both sumex and umich.  A couple of good books are:
  106.  
  107.    _Computer_Graphics_ 2nd ed by Hearn & Baker ISBN 0-13-161530-0
  108.  
  109.    _3D_Computer_Graphics_ 2nd ed by Alan Watt  ISBN 0-201-63186-5
  110.  
  111.   One general procedure is to imagine your "object" in 3D space 
  112.     (say with x,y,z co-ords centered around 0,0,0 to start),
  113.     then imagine an "observer" in the same space (say at x,y,z=0,0,100)
  114.     and a perpandicular plane between them (say at z= 70).
  115.  
  116.   Rotate, translate or do whatever to the object (working in cartesian it's
  117.     pretty easy - it's also handy to add a fourth parameter as a scaler
  118.     for xy&z - say t) then imagine vectors from the observer to each
  119.     point of your object (say the vertices of the cube).  The points
  120.     where your vectors intersect the plane are the points you want
  121.     to map to your graphics port.  Then just connect the dots in your
  122.     graphics port.  With wire frame, you don't have to worry 'bout 
  123.     which point is closer to the observer. 
  124.  
  125.   Hmmm... not the best explanation, but I'm kind of new to this too.
  126.     Check out those books (or anything around T385 in your library), 
  127.     it's a lot easier than it seems at first.  Luck,
  128.  
  129.                                             -- nick
  130.  
  131.  
  132.     
  133.  
  134.  
  135.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  136.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  137.  _/ _/_/  _/  _/       _/ _/
  138. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  139.  
  140.  
  141. +++++++++++++++++++++++++++
  142.  
  143. >From cconstan@epdiv1.env.gov.bc.ca (Carl B. Constantine)
  144. Date: Wed, 06 Jul 1994 07:40:20 -0700
  145. Organization: Ministry of Environment, Lands & Parks
  146.  
  147. In article <nick.1123818761C@usenet.pitt.edu>, nick@pitt.edu ( nick.c ) wrote:
  148.  
  149. > In Article <0007E5C6.fc@nile.com>, Malicious_Monarch@nile.com (Malicious
  150. > Monarch) wrote:
  151. > >     Please understand that I'm not concerned with a user interface at this
  152. > >point, just simple rendering code (ie making a cube and rotating it to
  153. give the
  154. > >illusion that it is a three dimensional object).  If someone could
  155. point toward
  156. > >some source code, or any literature (books, magazines, etc.) I would really
  157. > >really appreciate it.  Thanks...
  158. >   There is some code called "wireframeorama" (or something like that)
  159. >     that's at both sumex and umich.  A couple of good books are:
  160.  
  161. [ snip ]
  162.  
  163. I have a good file (better than wireframeorama) that uses the Graph3D
  164. library and rotates and scales (I think) an object in 3D space.
  165.  
  166. e-mail me if you're interested.  I may post it (it's small)
  167.  
  168. -- 
  169. ========================================================================
  170. Carl B. Constantine                  B.C. Environment, Lands & Parks
  171. End-User Support Analyst             CCONSTAN@epdiv1.env.gov.bc.ca
  172.  PGP Key available if you finger: CCONSTAN@EUSACBC.env.gov.bc.ca
  173.  
  174. +++++++++++++++++++++++++++
  175.  
  176. >From kenlong@netcom.com (Ken Long)
  177. Date: Wed, 6 Jul 1994 15:32:47 GMT
  178. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  179.  
  180. On devtools.symantec.com there's a file called 3DGraphics (something like 
  181. that) which is a port to C from the old Lisa Pascal "Boxes" and 
  182. "BoxSpheres" programs sources.  Uses the Graf3D lib.
  183.  
  184. There are some rotaters on alt.sources.mac's home site.  One is a color 
  185. Graf3D thing written by jjcii@aol.com, as a learning tool for Graf3D.  
  186. One is a revival of some old code called "ROT-PSIG" in the snippets as 
  187. rotpsig2.  Lots of comments in this file, on the whole rotation thing 
  188. (non-Graf3D).
  189.  
  190. I've got 3 Pascal source (the C port doesn't run yet) for 
  191. rotating/animating 3D spheres and geometric shapes.  One came from AOL 
  192. and one from the CUMUG files.  Icosahedron6 is the latter.  Both use 
  193. "light sources" and thus shading.
  194.  
  195. -Ken-
  196.  
  197. ---------------------------
  198.  
  199. >From white@cs.sfu.ca (Steve &)
  200. Subject: CASE Tools for Macintosh
  201. Date: 29 Jun 1994 20:16:59 GMT
  202. Organization: Department of Mathematics and Statistics, Simon Fraser University
  203.  
  204. I've been looking into CASE tools for use with the Mac, and from a run
  205. through several issues of the Journal of Object Oriented Programming (JOOP)
  206. and Object Magazine (OM); I've found four.
  207.  
  208. This is a pretty crappy summary of what I found, but I hope to add to it.
  209.  
  210. If you know of or sell any others, please let me know and I'll post a better
  211. summary.  I'd quite like to hear of any experiences you have had with
  212. any Mac CASE tool, or of any review articles in MacUser or Mac World.
  213.  
  214. Cheers!
  215. ______________________________________________________________________________
  216. Vendor    Berard Software     Excel software  Iconix Software   Object Inter-
  217.           Engineering Inc                     Engineering       national, Inc
  218.  
  219. Tool      The Berard Object   MacAnalyist,    ObjectModeler     ObjecTool
  220.           and Class Specifier MacDesigner
  221.  
  222. Method    Berard, &c          ?               Rumb, &c          ?
  223.  
  224. platform  Mac "this summer",  Mac             Mac, others soon  all(!)
  225.           Win, OS/2
  226.           
  227. advert    p34 OM Sep 93       p45 OM Sep 93   p8 OM Dec 93      p6 OM Sept 93
  228.  
  229. review    p85 OM Sep 93                       p98 OM Nov 92     p94 JOOP v6#3
  230.  
  231. price $US 595                                                   995
  232.  
  233. code gen? Y                                                     Y
  234.  
  235. +++++++++++++++++++++++++++
  236.  
  237. >From nbhatia@netcom.com (Naresh Bhatia)
  238. Date: Sat, 2 Jul 1994 19:31:53 GMT
  239. Organization: MultiQuest Corporation
  240.  
  241. Steve & (white@cs.sfu.ca) wrote:
  242. : I've been looking into CASE tools for use with the Mac, and from a run
  243. : through several issues of the Journal of Object Oriented Programming (JOOP)
  244. : and Object Magazine (OM); I've found four.
  245.  
  246. : If you know of or sell any others, please let me know and I'll post a better
  247. : summary.
  248.  
  249. MultiQuest Corporation offers an object-oriented tool, called S-CASE, 
  250. that implements the Booch method. The Mac version is $249. I am attaching 
  251. a short summary for your information.
  252.  
  253. Naresh Bhatia
  254. MultiQuest Corporation
  255.  
  256.  
  257. S-CASE  is  a  multi-user  software  engineering  tool that supports the
  258. Booch method  of object-oriented  design. The  product allows developers
  259. to create models of their systems using graphical tools that  understand
  260. the  semantics  of  the  Booch  methodology.  C++  code can be generated
  261. automatically from  these models.  S-CASE is  one of  the first tools of
  262. its kind  to operate  on heterogeneous  networks of  PC, Macintosh,  and
  263. UNIX workstations.
  264.  
  265. S-CASE allows developers to experiment with many design approaches. High
  266. level designs  can be  created quickly  and later  refined by filling in
  267. details about class methods and attributes.
  268.  
  269. The tool's C++ code generation  encourages engineers to spend more  time
  270. in the critical analysis and  design phases and spend less  time writing
  271. code. C++  headers and  method stubs  are generated  directly from class
  272. diagrams. The engineer simply fills in the body of the methods.
  273.  
  274. S-CASE lets you  conduct on-line interactive  design reviews. Ideas  are
  275. quickly conveyed to colleagues and customers through concise full  color
  276. diagrams. Presentation  quality output  provides hard  copy handouts and
  277. documentation.
  278.  
  279. S-CASE stores data in a platform independent format allowing  multi-user
  280. access across different platforms.
  281.  
  282. Available immediately, S-CASE lists at:
  283.            $249  MS Windows and Macintosh
  284.            $995  Sun SPARC and HP 9000
  285.            (floating and site licenses also available)
  286.  
  287. Demos can be downloaded via  anonymous ftp at ftp.netcom.com. The  demos
  288. are under /pub/showcase.
  289.  
  290. The  Microsoft  Windows  demo  is  also  available  on CompuServe in the
  291. CASEFORUM. The demo is named  "showcase.zip" and is located in  the CASE
  292. library.
  293.  
  294. For further information please contact:
  295.  
  296.               ------------------------------------------
  297.                         MultiQuest Corporation
  298.                   1699 East Woodfield Road, Suite A-1
  299.                        Schaumburg, IL 60173, USA
  300.  
  301.                           Tel: (708) 240-5555
  302.                           Fax: (708) 240-5556
  303.                    Email: 72531.2510@compuserve.com
  304.               ------------------------------------------
  305.  
  306.  
  307. +++++++++++++++++++++++++++
  308.  
  309. >From Lars.Farm@nts.mh.se (Lars Farm)
  310. Date: Mon, 04 Jul 1994 08:38:06 +0100
  311. Organization: Mid Sweden University
  312.  
  313. In article <nbhatiaCsBvL5.HF0@netcom.com>, nbhatia@netcom.com (Naresh
  314. Bhatia) wrote:
  315.  
  316. > Steve & (white@cs.sfu.ca) wrote:
  317. > : I've been looking into CASE tools for use with the Mac, and from a run
  318. > : through several issues of the Journal of Object Oriented Programming (JOOP)
  319. > : and Object Magazine (OM); I've found four.
  320. > : If you know of or sell any others, please let me know and I'll post a better
  321. > : summary.
  322. > MultiQuest Corporation offers an object-oriented tool, called S-CASE, 
  323. > that implements the Booch method.
  324.  
  325. S-CASE? So they changed the name? I know it as Showcase and it is nice. Has
  326. editors for (new) Booch class diagrams and (new) Booch object interaction
  327. diagrams. Quite useful and usable! (even though the "crossplatform" nature
  328. shines through in some details.)
  329.  
  330. Lars
  331.  
  332. -- 
  333. Lars.Farm@nts.mh.se
  334.  
  335. ---------------------------
  336.  
  337. >From boris@world.std.com (Boris Levitin)
  338. Subject: Debugging an applet properly (AppleScript)
  339. Date: Tue, 5 Jul 1994 11:41:58 GMT
  340. Organization: The World @ Software Tool & Die
  341.  
  342. I'm writing a large AppleScript applet, and have two problems:
  343.  
  344. 1. I need to have a reliable way to refer to the applet's own
  345. parent folder, because that's where I store some configuration
  346. files the applet uses (I don't want to hardcode the path).
  347. "path to me" returns the path to the applet only when it's running
  348. as an applet. When it's run from inside Script Editor, "me" is
  349. interpreted to be Script Editor -- not the desirable effect. I'm
  350. tired of having to hardcode in a path every time I need to debug
  351. the applet; is there any way to say, path to this very script file?
  352.  
  353. 2. I have a large idle handler in my applet, and there doesn't seem
  354. to be a way to have Script Editor send an idle message to the applet
  355. when it's being debugged in it. Consequently, I have to comment out
  356. the on idle and end idle statements every time I debug. It's annoying,
  357. like item 1.
  358.  
  359. I would appreciate any suggestions.
  360.  
  361.  
  362. -- 
  363. Boris Levitin                                  WGBH Public Broadcasting, Boston
  364.                                    boris@world.std.com * boris_levitin@wgbh.org
  365.  
  366. +++++++++++++++++++++++++++
  367.  
  368. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  369. Date: Wed, 6 Jul 1994 16:22:59 GMT
  370. Organization: Apple Computer
  371.  
  372. Boris Levitin, boris@world.std.com writes:
  373. > "path to me" returns the path to the applet only when it's running
  374. > as an applet. When it's run from inside Script Editor, "me" is
  375. > interpreted to be Script Editor -- not the desirable effect. I'm
  376. > tired of having to hardcode in a path every time I need to debug
  377. > the applet; is there any way to say, path to this very script file?
  378.  
  379. Nope. AppleScript has no idea where the script it's executing is stored.
  380.  
  381. > 2. I have a large idle handler in my applet, and there doesn't seem
  382. > to be a way to have Script Editor send an idle message to the applet
  383. > when it's being debugged in it.
  384.  
  385. Not unless you explicitly say "idle" in your main body or 'on run' handler.
  386. The runtime environment of an applet is different than one being run by the
  387. editor, so it wouldn't really make sense for a script to be sent idle events
  388. while in the editor.
  389.  
  390. These things have both annoyed me too. But I couldn't think of a clean
  391. solution that didn't involve major reworking of the way scripts are edited in
  392. AS 1.X.
  393.  
  394. --Jens Alfke
  395.   jens_alfke@powertalk              Rebel girl, rebel girl,
  396.             .apple.com              Rebel girl you are the queen of my world
  397.  
  398. +++++++++++++++++++++++++++
  399.  
  400. >From jwbaxter@olympus.net (John W. Baxter)
  401. Date: Wed, 06 Jul 1994 12:19:45 -0700
  402. Organization: Internet for the Olympic Peninsula
  403.  
  404. In article <CsGttz.4o9@world.std.com>, boris@world.std.com (Boris Levitin)
  405. wrote:
  406.  
  407. > I'm writing a large AppleScript applet, and have two problems:
  408. > 1. I need to have a reliable way to refer to the applet's own
  409. > parent folder, because that's where I store some configuration
  410. > files the applet uses (I don't want to hardcode the path).
  411. > "path to me" returns the path to the applet only when it's running
  412. > as an applet. When it's run from inside Script Editor, "me" is
  413. > interpreted to be Script Editor -- not the desirable effect. I'm
  414. > tired of having to hardcode in a path every time I need to debug
  415. > the applet; is there any way to say, path to this very script file?
  416. >
  417. > 2. I have a large idle handler in my applet, and there doesn't seem
  418. > to be a way to have Script Editor send an idle message to the applet
  419. > when it's being debugged in it. Consequently, I have to comment out
  420. > the on idle and end idle statements every time I debug. It's annoying,
  421. > like item 1.
  422.  
  423. You might give Script Wizard a try (there is a demo [can't save scripts]
  424. version available at
  425.  
  426.   ftp://gaea.kgs.ukans.edu:applescript/demos/ScriptWiz.Demo.sit.hqx
  427.  
  428. (there's a press release "beside" the demo file in the same directory).
  429.  
  430. Note that I say "try":  I don't know whether "they" addressed the idle
  431. question or not.  Script Wizard is one of two OSA script editors recently
  432. announced, to fill the high-end of the editing services spectrum (it is
  433. said that Apple intentionally left that end open for third parties).  The
  434. other one isn't quite out yet.
  435.  
  436. Meanwhile...for debugging, I'd hard-code a path.  When the path to me
  437. returns a path to the Script Editor, have the run handler pass your action
  438. code the hard-coded path...otherwise have it pass the result from path to
  439. me.  Just remember not to give your script editor a clever name which
  440. breaks your test.
  441.    if (path to me) contains "Script Editor" then ...
  442.  
  443. --John
  444.  
  445. -- 
  446. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  447.    No hablo Intel.
  448.    jwbaxter@pt.olympus.net
  449.  
  450. ---------------------------
  451.  
  452. >From hoyer@cc.Helsinki.FI (P. Hoyer)
  453. Subject: GWorlds vs. Offscreens
  454. Date: 18 Jun 1994 02:03:40 +0300
  455. Organization: University of Helsinki
  456.  
  457. Once again, Hello netters!
  458.  
  459. Since it's almost 2 A.M. here in Finland and I'm waiting for the Spain
  460. vs. South-Korea soccer game to begin, I thought I'd ask a question that
  461. has long been on my mind.
  462.  
  463. I've been using regular old-style offscreen grafports (both 8-bit and
  464. b&w) for a few years now, and since I have reusable code to create these
  465. offscreens, I've never taken the trouble to really find out how GWorlds
  466. differ from these offscreens. Since I don't own the latest in Inside
  467. Macs, I can't look it up there.
  468.  
  469. So, what are the advantages of GWorlds? Is there really any reason to
  470. switch from offscreen grafports? I guess the main argument would be
  471. "they're easier to use" but since I already have working routines
  472. offscreens aren't a problem for me.
  473.  
  474. If this message is a bit unclear, it's only 'cause it's 02:04 in the
  475. morning and I'm tired as hell... :)
  476.  
  477. -P. Hoyer <hoyer@cc.helsinki.fi>
  478.  
  479. +++++++++++++++++++++++++++
  480.  
  481. >From Mark Hanrek <hanrek@cts.com>
  482. Date: Sat, 18 Jun 1994 13:08:48 GMT
  483. Organization: The Information Workshop
  484.  
  485. In article <2tta4c$585@kruuna.Helsinki.FI> P. Hoyer, hoyer@cc.Helsinki.FI
  486. writes:
  487.  
  488. > So, what are the advantages of GWorlds? Is there really any reason to
  489. > switch from offscreen grafports? I guess the main argument would be
  490. > "they're easier to use" but since I already have working routines
  491. > offscreens aren't a problem for me.
  492.  
  493. Well, as they say, "if it ain't broke, don't fix it".  If you are having
  494. good luck, then by all means don't change unless you need to.
  495.  
  496.  
  497. The advantages of GWorlds that come to mind include...
  498.  
  499. * Apple is responsible for the source code, not me. :)
  500.   ( this is my favorite advantage :)
  501.  
  502. * One simple call handles the creation of an entire GWorld, 
  503.   which includes the pixmap, grafport, and graphic device,
  504.   and color table.
  505.  
  506. * GWorlds handle aligning themselves with destination screen.
  507.  
  508. * Passing 0 for the bit depth causes GWorlds to pick up the 
  509.   attributes of the screen containing the majority of the 
  510.   passed global rectangle, automatically.
  511.  
  512. * After you create the GWorld, there are calls to conveniently 
  513.   obtain the pixmapHandle so you can lock it
  514.  
  515. * A single call (UpdateGWorld) will do whatever is necessary to 
  516.   ensure that the GWorld is totally optimized for fastest transfer
  517.   to the screen, including aligning its pixels with the screen's,
  518.   and making sure the source and destination color tables match.
  519.  
  520. * Pixels can be purged and restored, and also cached on a NuBus card
  521.   based graphics accelerator transparently.
  522.  
  523. There may be more advantages.
  524.  
  525.  
  526. The benefit of GWorlds handling and hiding all of the concerns 
  527. of graphic devices has allowed me to have the confidence that my
  528. software will work on any screen out there, and I didn't have to
  529. learn a single thing about the internals of graphic devices!
  530.  
  531. But as I say, the best part is that Apple maintains the code.
  532.  
  533. I am totally certain that there is at least one thing in their
  534. code that I would have never figured out.  :)
  535.  
  536. But also, if your's works fine, don't change it unless you must.
  537.  
  538. Spend your time, instead, on your struggle to get your palettes and
  539. color tables working properly.  :)
  540.  
  541. - ---------
  542.  
  543. When it comes to Palettes and Color Tables, there IS a big need
  544. for some help in this area.  There are almost no examples, and
  545. Forest Tanaka mentioned once that there won't be much new
  546. in this area, if anything, in Quickdraw/GX.
  547.  
  548. It took me days and days of trying every combination and permutation
  549. to zero in on what I am supposed to do, so that I am a courteous guy
  550. with respect to other applications and their color needs.  These 
  551. "interapplication issues" are not documented, nor is there example
  552. source code that has everything working together, and I have 
  553. scoured the earth in search of some.
  554.  
  555. BTW, in one's update event handler, you can include a call to
  556. UpdateGWorld.  If everything is fine, then it returns immediately.
  557.  
  558. If, however, the user moved into the background, and now the other 
  559. app's color table is in control, or the user changed the bit depth,
  560. then UpdateGWorld will either handle the situation for you ( and
  561. there will be a slight delay ) or you will get the signal that
  562. you must redraw your graphics into the GWorld because the user
  563. increased the bit depth ( since the color detail was lost when the
  564. user decreased the bit depth ).
  565.  
  566. Ensuring the color tables match has a BIG impact on performance. The
  567. difference is easily perceptible.
  568.  
  569. If you put a call to UpdateGWorld whenever the window is moved or
  570. resized, then you can rest assured your pixels will be automatically
  571. realigned, if necessary, for optimum performance as well.
  572.  
  573.  
  574. Hope this helps.
  575.  
  576. Mark Hanrek
  577.  
  578. +++++++++++++++++++++++++++
  579.  
  580. >From hoyer@cc.Helsinki.FI (P. Hoyer)
  581. Date: 18 Jun 1994 22:09:43 +0300
  582. Organization: University of Helsinki
  583.  
  584. >
  585. > But as I say, the best part is that Apple maintains the code.
  586. >
  587.  
  588. So what you essentially mean is that GWorlds are less likely to break
  589. when Apple decides to move stuff around and change stuff? This seems
  590. like a good reason to switch sooner or later...
  591.  
  592. >
  593. > But also, if your's works fine, don't change it unless you must.
  594. >  
  595. > Spend your time, instead, on your struggle to get your palettes and
  596. > color tables working properly.  :)
  597.  
  598. Well, since I've mostly written simple games which use the System
  599. palette, I haven't had to worry about colors really. Now, I'm making a
  600. little more serious game that will probably need a custom
  601. palette...hmmm, I think I ought to get some example code on GWorlds.
  602. Would anybody happen to have any good sample code?
  603.  
  604. I read about the Palette Manager in IM V (it's the latest I've got). Has
  605. it evolved much since the days of the MacII? ;)
  606.  
  607. -P. Hoyer <hoyer@cc.helsinki.fi>
  608.  
  609. +++++++++++++++++++++++++++
  610.  
  611. >From Mark Hanrek <hanrek@cts.com>
  612. Date: Sat, 18 Jun 1994 23:24:18 GMT
  613. Organization: The Information Workshop
  614.  
  615. In article <2tvgpn$ror@kruuna.Helsinki.FI> P. Hoyer, hoyer@cc.Helsinki.FI
  616. writes:
  617.  
  618. > I read about the Palette Manager in IM V (it's the latest I've got).
  619. > Has it evolved much since the days of the MacII? ;)
  620.  
  621. Not much. I think there are were some updating options added.
  622.  
  623.  
  624. As for examples, there are tons of them.  You will want to download files
  625. you find in the development source code areas of umich and sumex, in
  626. addition to ftp.apple.com.
  627.  
  628. DTS.lib is also an excellent reference.
  629.  
  630. Also, there are lots of examples all over the Developer CD, and a must
  631. have article is "Drawing in GWorlds for Speed and Versatility" from the
  632. May '92 issue of develop (includes source code).
  633.  
  634. Also, I have learned a lot from GMonde, and ResetColors, both by Forest
  635. Tanaka.
  636.  
  637. Hope this helps.
  638.  
  639. Mark Hanrek
  640.  
  641. +++++++++++++++++++++++++++
  642.  
  643. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  644. Date: 21 Jun 94 14:16:17 +1200
  645. Organization: University of Waikato, Hamilton, New Zealand
  646.  
  647. In article <CrLGIq.FFM@crash.cts.com>, Mark Hanrek <hanrek@cts.com> writes:
  648. >
  649. > The advantages of GWorlds that come to mind include...
  650. (lots of good ones omitted).
  651.  
  652. It is true. GWorlds take care of 90% of your needs. As one who started messing
  653. about with Color QuickDraw on one of the first Mac II's to hit New Zealand
  654. (back in 1987), it is *much* less fiddly to use GWorlds than to try to create
  655. your own GDevices.
  656.  
  657. However, there are a few things you can't do with GWorlds. For a start, you
  658. can't create a GWorld that does its drawing into a pre-existing pixmap.
  659.  
  660. In deference to my current enthusiasms, I should point out that the
  661. offscreen support in QuickDraw GX doesn't suffer from this problem. :-)
  662.  
  663. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  664. Info & Tech Services Division              fax: +64-7-838-4066
  665. University of Waikato            electric mail: ldo@waikato.ac.nz
  666. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  667.  
  668. +++++++++++++++++++++++++++
  669.  
  670. >From Alex Kac <akac@delphi.com>
  671. Date: Fri, 1 Jul 94 23:33:06 -0500
  672. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  673.  
  674. See if you can get the MacTech magazine from (I think...), April and May which
  675. have a complete tutorial on using GWorlds...
  676.  
  677. ---------------------------
  678.  
  679. >From Gordon Graber <gg4921s@Acad.Drake.Edu>
  680. Subject: GWorlds: When to lock pixels?
  681. Date: 6 Jul 1994 13:14:55 GMT
  682. Organization: Drake University
  683.  
  684. How Do All,
  685. Several questions about locking a GWorlds pixels:
  686. 1.  Must you lock the pixels to the GWorld if you have specified
  687. NoPurgePixels for the GWorld?
  688. 2.  If drawing and copyBitsing between several GWorlds in a loop, can one
  689. lock the pixels for each GWorld before the start of the loop and then
  690. unlock them after the loop is done executing?
  691. 3.  If you knew you were going to access several GWorlds often in a
  692. program, why not lock the pixels at the outset and unlock them when the
  693. program ends?
  694. 3a.  If this results in some kind of memory fragmentation, is there a way
  695. of optimizing this? ( like moveHi(); Lock(); ?)
  696. 4.  Why do you not have to lock the pixels to the main screen, or do you?
  697. 5.  Are there any conditions, possible exceptions above, under which one
  698. does not need to lock the pixels?
  699.  
  700. Thanks for any help,
  701.   Gordon Graber:  gg4921s@acad.drake.edu
  702.  
  703. +++++++++++++++++++++++++++
  704.  
  705. >From ctaylor@fox.nstn.ns.ca (Christian Taylor)
  706. Date: 6 Jul 1994 11:31:40 -0300
  707. Organization: Nova Scotia Technology Network
  708.  
  709. As far as I know, you should always lock the pixels when you're drawing. 
  710. Most drawing commands are safe and don't move memory, but things like
  711. PlotIcon do, and you'll lock up the computer if you leave the pixels
  712. unlocked.  When I create a GWrold, I usually lock the pixels right after
  713. and the unlock them in my de-init routine.
  714.  
  715. Christian
  716.  
  717.  
  718. +---------------------+----------------------------------+
  719. |  Christian Taylor   | Internet: ctaylor@fox.nstn.ns.ca |
  720. |The Party Palace BBS | CIS     : 71442,1161             |
  721. |   (902) 679-1218    | AOL     : Chris1020              |
  722. +---------------------+----------------------------------+
  723.  
  724. +++++++++++++++++++++++++++
  725.  
  726. >From al@crucible.powertools.com (Al Evans)
  727. Date: 6 Jul 94 14:35:09 GMT
  728. Organization: PowerTools, Austin, Texas
  729.  
  730. In article <2veaof$ru@dunix.drake.edu> gg4921s@Acad.Drake.Edu (Gordon Graber) writes:
  731.  
  732. >Several questions about locking a GWorlds pixels:
  733.  
  734. >1.  Must you lock the pixels to the GWorld if you have specified
  735. >NoPurgePixels for the GWorld?
  736.  
  737. Yes. NoPurgePixels simply keeps the pixels in memory. It doesn't keep
  738. them from moving. Incidentally, pixels are non-purgeable by default --
  739. unless you've made them purgeable on creation or later, they'll stay
  740. around.
  741.  
  742. >2.  If drawing and copyBitsing between several GWorlds in a loop, can one
  743. >lock the pixels for each GWorld before the start of the loop and then
  744. >unlock them after the loop is done executing?
  745.  
  746. Yes, unless memory is really tight and/or there is a lot of allocation
  747. and deallocation within the loop in question. 
  748.  
  749. >3.  If you knew you were going to access several GWorlds often in a
  750. >program, why not lock the pixels at the outset and unlock them when the
  751. >program ends?
  752.  
  753. Unless memory is really tight and/or (et cetera), this is a good thing
  754. to do. To the extent that you can do so, allocate all the memory you'll
  755. need at startup, and lock it down.
  756.  
  757. >3a.  If this results in some kind of memory fragmentation, is there a way
  758. >of optimizing this? ( like moveHi(); Lock(); ?)
  759.  
  760. I don't know whether this is "guaranteed", but in my experience
  761. LockPixels() already does a MoveHi().
  762.  
  763. >4.  Why do you not have to lock the pixels to the main screen, or do you?
  764.  
  765. Because they can't move. Even if you physically move your monitor, the
  766. graphics memory for that monitor stays in the same place:-)
  767.  
  768. >5.  Are there any conditions, possible exceptions above, under which one
  769. >does not need to lock the pixels?
  770.  
  771. You don't need to lock them if 1) you are operating on them entirely
  772. from within your own code, without calling ToolBox routines, and 2)
  773. if you don't do any memory allocation/deallocation from within that
  774. code. They will stay where they are unless there's a reason for them
  775. to move.
  776.                     --Al Evans--
  777. -- 
  778. Al Evans            |   Graphic Elements: A new standard for 
  779.                 |   high-performance interactive Macintosh graphics.
  780. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  781.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  782.  
  783. +++++++++++++++++++++++++++
  784.  
  785. >From Mark Hanrek <hanrek@cts.com>
  786. Date: Wed, 6 Jul 1994 15:33:56 GMT
  787. Organization: The Information Workshop
  788.  
  789. In article <454@crucible.powertools.com> Al Evans,
  790. al@crucible.powertools.com writes:
  791.  
  792. >>4. Why do you not have to lock the pixels to the main screen ?
  793. >
  794. > Because they can't move. Even if you physically move your monitor, the
  795. > graphics memory for that monitor stays in the same place :-)
  796. >
  797.  
  798. Al,
  799.  
  800. You crack me up! :) :) :)
  801.  
  802. Mark
  803.  
  804. ---------------------------
  805.  
  806. >From tfullert@bottom.magnus.acs.ohio-state.edu (tfullert)
  807. Subject: How do you write TIFFs?
  808. Date: 6 Jul 1994 17:32:44 GMT
  809. Organization: The Ohio State University
  810.  
  811. Greetings:
  812.  
  813. I am developing an application where I must export graphics as TIFFs. 
  814. Does any free source exist for this exist?  Where might I find it?
  815.  
  816. Thanks.
  817.  
  818. Tim
  819.  
  820. +++++++++++++++++++++++++++
  821.  
  822. >From Mark Hanrek <hanrek@cts.com>
  823. Date: Thu, 7 Jul 1994 01:47:33 GMT
  824. Organization: The Information Workshop
  825.  
  826. Subject: How do you write TIFFs?
  827. From: tfullert, tfullert@bottom.magnus.acs.ohio-state.edu
  828. Date: 6 Jul 1994 17:32:44 GMT
  829. In article <2veprs$gh2@charm.magnus.acs.ohio-state.edu> tfullert,
  830. tfullert@bottom.magnus.acs.ohio-state.edu writes:
  831.  
  832. > Greetings:
  833. >
  834. > I am developing an application where I must export graphics as TIFFs. 
  835. > Does any free source exist for this exist?  Where might I find it?
  836. >
  837. > Thanks.
  838. >
  839. > Tim
  840.  
  841.  
  842. Tim,
  843.  
  844. I suggest you use Archie, because it will easily pull up trillions of
  845. places where TIFF source code can be found.  This is usually a package by
  846. Sam Leffler for unix systems.
  847.  
  848. Also, the URT (Utah Raster Toolkit) has TIFF writing code. ( University
  849. of Utah :).
  850.  
  851. A package called MegaTIFF can be found on AppleLink ( I think that is Sam
  852. Leffler's package kinda ported to MPW ).
  853.  
  854. You will also want to look on CompuServe, which is where the "Aldus
  855. Developer Desk" lives, and example source code can be found there, in
  856. addition to the test suite of TIFF pictures.
  857.  
  858. You will also want to definitely have your own copy of the TIFF 6.0
  859. Specification.  Get it and print it from the PostScript formatted
  860. version.  It is a beautiful and well-written document that will clarify
  861. many things for you. ( wierd, huh? :)
  862.  
  863. This document can be found on umich, and possibly sumex.
  864.  
  865. The other things I can think of only decode TIFF, and I've mentioned all
  866. the good stuff anyway.
  867.  
  868.  
  869. Hope this helps.
  870.  
  871. Mark Hanrek
  872.  
  873. +++++++++++++++++++++++++++
  874.  
  875. >From rgc3679@halcyon.com (Bob Carpenter)
  876. Date: Wed, 06 Jul 1994 20:34:28 -0800
  877. Organization: Northwest Nexus Inc.
  878.  
  879. In article <2veprs$gh2@charm.magnus.acs.ohio-state.edu>,
  880. tfullert@bottom.magnus.acs.ohio-state.edu (tfullert) wrote:
  881.  
  882. > Greetings:
  883. > I am developing an application where I must export graphics as TIFFs. 
  884. > Does any free source exist for this exist?  Where might I find it?
  885.   At SGI's anonymous ftp sit (ftp.sgi.com) in directory: graphics/tiff
  886.   you'll find much information and source code for working with TIFFs.
  887.   You'll also find the latest version of the TIFF specification (6).
  888.  
  889.   You may also want to subscribe to the tiff mailing list by sending
  890.   the word subscribe in the body of a message to:
  891.  
  892.     majordomo@whizzer.wpd.sgi.com
  893.  
  894. -- 
  895. --BobC
  896.  
  897. ---------------------------
  898.  
  899. >From tzs@u.washington.edu (Tim Smith)
  900. Subject: How to tell Energy Saver to turn the monitor on or off
  901. Date: 4 Jul 1994 13:35:09 GMT
  902. Organization: University of Washington School of Law, Class of '95
  903.  
  904. A few months ago, I spent a while disassembling Apple's Energy Saver
  905. control panel to figure out how it worked.  I needed to know this
  906. because I wanted to make it work for me under A/UX.  That effort was
  907. a success, allowing me to create an extension, Energy Beaver, that
  908. loads before Energy Saver under A/UX, and diddles a few things so
  909. that Energy Saver will be happy.  (Energy Beaver, plus source code,
  910. is available on ftp.u.washington.edu, in public/tzs, if anyone wants
  911. it).
  912.  
  913. A couple of weeks ago, someone asked me via email how one interfaces
  914. to Energy Saver.  They wanted to add Energy Saver support to a screen
  915. saver they were working on.  It occured to me that this might be of
  916. interest to others, so I decided to post a copy of my response here.
  917. That is appended at the end of this post.
  918.  
  919. Apple's Energy Saver actually consists of three components.  A
  920. driver that patches into the video driver and actually does the
  921. hardware manipulation (this driver is contained in an INIT
  922. resource, so you won't find a DRVR in the Energy Saver file),
  923. an INIT that is basically a screen saver that calls the driver
  924. when it is time to blank the screen or unblank it, and a CDEV
  925. that provides the interface.  When you turn Energy Saver off
  926. from the CDEV, all you are really doing is telling the screen
  927. saver INIT to turn off.  The driver is still active, and can
  928. be called from other software to turn the monitor off and on.
  929.  
  930. - --------- copy of letter follows --------
  931.  
  932. Hello;
  933.  
  934.     I've looked at the Energy Saver disassembly, and done a little
  935. experimenting.  Here's the information you need, I think.
  936.  
  937. 1. Determining if Energy Saver supports a particular video card.
  938.  
  939. Issue a status call to the driver, with csCode=11, and csParam containing
  940. a pointer to a data area of 6 bytes.  I don't think it matters what you
  941. place in this data area, but Apple places zeros there, so I'd do that
  942. too.  If this control call does not return an error, then the Energy
  943. Saver driver is installed for that monitor.
  944.  
  945. 2. To enter Energy Saving mode.
  946.  
  947. Step through the graphics device list.  For each device, determine if
  948. Energy Saver is installed for that device using that above test.  For
  949. each that it is, do a control call with csCode=11 (that's decimal 11,
  950. not hex 11), and csParam containing a pointer to a data area of six
  951. bytes.  In that six bytes, place the following: 0x01, 0x01, 'H', 'A',
  952. 'L', ' '.
  953.  
  954. 3. To exit Energy Saving mode.
  955.  
  956. This is similar to entering Energy Saving mode, except that those first
  957. two bytes of the six byte data area should be 0x00 and 0x00 instead of
  958. 0x01 and 0x01.
  959.  
  960. After you've turned everything on, for each monitor do a status call
  961. with csCode=11, and csParam containing a pointer to six bytes of data.
  962. Fill out that data area with 0x00, 0x00, 'H', 'A', 'L', ' ' before
  963. doing the call.  After the status call, check byte 1 of the six byte
  964. data area (numbered from 0).  If that byte ANDed with 0x80 is non-zero,
  965. then do the following:
  966.  
  967.         short temp = (*g)->gdMode & 0xffff;
  968.         (*g)->gdMode = 0;
  969.         SetDepth(g,temp,0,0);
  970.  
  971. where g is a handle to the GDevice record for the monitor.
  972.  
  973. After you've set the depth on all the monitors that need it, call
  974. DrawMenuBar.
  975.  
  976. 4. Some observations.
  977.  
  978. I don't think it matters whether or not the 'HAL ' stuff is placed in
  979. the six byte data area in the control and status calls.  I didn't
  980. notice anything that checked for this in the driver that handles these
  981. calls when I disassembled them.
  982.  
  983. Energy Saving mode seems to scramble some of the VRAM.  When it comes
  984. out of Energy Saving mode, there are random colored pixels scattered
  985. around.  That business with SetDepth seems to be to get everyone to
  986. update the screen.  If you are doing this from a screen saver, presumably
  987. you will already be making everyone redraw, so you probably don't need
  988. this.
  989.  
  990. The status call seems to modify the first two bytes of the six byte data
  991. area pointed to be csParam.  I do not know what the significance of byte 1
  992. is, other than it seems to contain that flag that tells if the monitor
  993. needs to have the screen redrawn to clean up the garbage.  Byte 0 seems
  994. to get written with 0x00 if the monitor is not in Energy Saving mode,
  995. and 0xFF if it is.  Apple's software does not seem to make use of this,
  996. so it is not clear that it is safe to rely on it.
  997.  
  998. 5. Sample code.
  999.  
  1000. Here is a simple program fragment that enters Energy Saving mode, waits for
  1001. a mouse click, and then leaves Energy Saving mode.
  1002.  
  1003.  
  1004.     CntrlParam    c;
  1005.     GDHandle    g;
  1006.     OSErr        e;
  1007.     short        res[3];        // the six byte data area
  1008.     
  1009.     //
  1010.     // We'll just do the first screen
  1011.     //
  1012.     g = GetDeviceList();
  1013.     
  1014.     c.ioCRefNum = (*g)->gdRefNum;
  1015.     c.csCode = 11;
  1016.     res[0] = 0; res[1] = 0; res[2] = 0;
  1017.     *(short **)(&c.csParam[0]) = &res[0];
  1018.     c.ioCompletion = 0;
  1019.     e = PBStatus( (ParmBlkPtr)&c, 0 );
  1020.     if ( e )
  1021.     {
  1022.         cout << "Energy Saver not supported!" << endl;
  1023.         return;
  1024.     }
  1025.  
  1026.     //
  1027.     // Turn monitor off
  1028.     //
  1029.     c.ioCRefNum = (*g)->gdRefNum;
  1030.     c.csCode = 11;
  1031.     res[0] = 0x0101; res[1] = 'HA'; res[2] = 'L ';
  1032.     *(short **)(&c.csParam[0]) = &res[0];
  1033.     c.ioCompletion = 0;
  1034.     e = PBControl( (ParmBlkPtr)&c, 0 );
  1035.     
  1036.     //
  1037.     // Pause until the mouse is clicked
  1038.     //
  1039.     while ( ! Button() )
  1040.         ;
  1041.     while ( Button() )
  1042.         ;
  1043.  
  1044.     //
  1045.     // Turn monitor back on
  1046.     //
  1047.     c.ioCRefNum = (*g)->gdRefNum;
  1048.     c.csCode = 11;
  1049.     res[0] = 0x0000; res[1] = 'HA'; res[2] = 'L ';
  1050.     *(short **)(&c.csParam[0]) = &res[0];
  1051.     c.ioCompletion = 0;
  1052.     e = PBControl( (ParmBlkPtr)&c, 0 );
  1053.     
  1054.     //
  1055.     // See if we need to set the depth to clean up the garbage
  1056.     //
  1057.     c.ioCRefNum = (*g)->gdRefNum;
  1058.     c.csCode = 11;
  1059.     res[0] = 0; res[1] = 'HA'; res[2] = 'L ';
  1060.     *(short **)(&c.csParam[0]) = &res[0];
  1061.     c.ioCompletion = 0;
  1062.     e = PBStatus( (ParmBlkPtr)&c, 0 );
  1063.     
  1064.     if ( res[0] & 0x0080 )
  1065.     {
  1066.         short temp = (*g)->gdMode & 0xffff;
  1067.  
  1068.         (*g)->gdMode = 0;
  1069.         SetDepth(g,temp, 0, 0 );
  1070.     }
  1071.     
  1072.  
  1073. ---------------------------
  1074.  
  1075. >From altitude@umich.edu (Alex Tang)
  1076. Subject: Newbie Gworld questions.
  1077. Date: 3 Jul 1994 14:11:22 GMT
  1078. Organization: University of Michigan
  1079.  
  1080. Hi folks.  I've got some pretty newbie'ish questions about Gworlds...
  1081.  
  1082. First, i haven't been able to find a good explaination about what they're
  1083. used for.  From the various bits of info that I've picked up, they
  1084. comprise of a lot of different graphics devices and tools (i.e. offscreen
  1085. drawing).  Is that right?  Is the main purpose for them so that offscreen
  1086. drawing is easier?
  1087.  
  1088. The main reason i'm asking is that I'm trying to write a small,
  1089. rudamentary graphics app.  It's something to teach me how to do
  1090. mac programming.  Basically, it's supposed be able to open some windows,
  1091. do some drawing into the wndows, and save the file as a PICT.  I've hit a
  1092. minor roadblock trying to figure out how where to draw the stuff and be
  1093. able to do updates on it.  At first, I thought I could draw directly to
  1094. the window, but that didn't work.  I'm trying to figure out if i need to
  1095. use gworlds for this (and i guess i should learn about them anyway).  
  1096.  
  1097. Well, Thanx for any insight that is provided.
  1098.  
  1099. ...alex...
  1100.  
  1101. --
  1102.     Alex Tang      |     UM-SNRE     |       UM-ITD/US Consultant II
  1103. ALTITUDE@UMICH.EDU |     Student     | http://www.snre.umich.edu/~altitude
  1104.   PGP via finger.  |  Systems Admin  | "Life's a game.  
  1105. This space for rent| Comp.Consut III |  play for fun, and play with Honor."
  1106.  
  1107. +++++++++++++++++++++++++++
  1108.  
  1109. >From gurgle@netcom.com (Pete Gontier)
  1110. Date: Mon, 4 Jul 1994 01:06:54 GMT
  1111. Organization: cellular
  1112.  
  1113. altitude@umich.edu (Alex Tang) writes:
  1114.  
  1115. >Is the main purpose for (GWorlds) so that offscreen drawing is easier?
  1116. >The main reason i'm asking is that I'm trying to write a small,
  1117. >rudamentary graphics app. ...it's supposed be able to open some
  1118. >windows, do some drawing into the wndows, and save the file as a PICT.
  1119.  
  1120. The question should be then, whether this drawing is going to require
  1121. you to use CopyBits. CopyBits is the routine used to shove bit maps and
  1122. pixel maps around in memory, on-screen and off-screen and in between
  1123. the two. You need it only if you need to do some image processing which
  1124. occurs as a side-effect of calls to CopyBits (colorizing bitmaps,
  1125. dithering, blending pixel maps, etc.) *or* you're trying to do some
  1126. updating which needs to be smooth or animated.
  1127.  
  1128. If the answer to this sort of question is "no", then don't bother with
  1129. GWorlds. Stick with Pictures. They're easier to deal with and they can
  1130. be translated almost directly into PICT files (such files are 512 bytes
  1131. of 0 followed by the contents of a PicHandle).
  1132.  
  1133. >I've hit a minor roadblock trying to figure out how where to draw the
  1134. >stuff and be able to do updates on it. At first, I thought I could draw
  1135. >directly to the window, but that didn't work...
  1136.  
  1137. Yes, and I understand the problem. Pictures will allow you to get around
  1138. this quite nicely, and in general in less memory than GWorlds, too.
  1139.  
  1140. Happy reading!
  1141. -- 
  1142.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  1143.  
  1144.  "...someone not acquainted with the Christian mythology of the
  1145.  Crucifixion might consider a Crucifix to be a particularly sadistic
  1146.  piece of erotica... We of the ACLU will continue to defend your right to
  1147.  worship such objects if it pleases you." -- Gregory J. Wageman
  1148.  
  1149. +++++++++++++++++++++++++++
  1150.  
  1151. >From Mark Hanrek <hanrek@cts.com>
  1152. Date: Mon, 4 Jul 1994 21:03:07 GMT
  1153. Organization: The Information Workshop
  1154.  
  1155. In article <2v6gua$62j@lastactionhero.rs.itd.umich.edu> Alex Tang,
  1156. altitude@umich.edu writes:
  1157.  
  1158. > Hi folks.  I've got some pretty newbie'ish questions about Gworlds...
  1159. >
  1160. > First, i haven't been able to find a good explaination about what
  1161. they're
  1162. > used for.  From the various bits of info that I've picked up, they
  1163. > comprise of a lot of different graphics devices and tools (i.e.
  1164. offscreen
  1165. > drawing).  Is that right?  Is the main purpose for them so that
  1166. offscreen
  1167. > drawing is easier?
  1168. >
  1169. > The main reason i'm asking is that I'm trying to write a small,
  1170. > rudamentary graphics app.  It's something to teach me how to do
  1171. > mac programming.  Basically, it's supposed be able to open some windows,
  1172. > do some drawing into the wndows, and save the file as a PICT.  I've hit
  1173. a
  1174. > minor roadblock trying to figure out how where to draw the stuff and be
  1175. > able to do updates on it.  At first, I thought I could draw directly to
  1176. > the window, but that didn't work.  I'm trying to figure out if i need to
  1177. > use gworlds for this (and i guess i should learn about them anyway).  
  1178. >
  1179. > Well, Thanx for any insight that is provided.
  1180. >
  1181. > ...alex...
  1182.  
  1183.  
  1184. Alex,
  1185.  
  1186. Here is the answer to all of your questions at once.  It is the answer
  1187. you were looking for...
  1188.  
  1189. As an illustrative example, let's say your application has one window
  1190. which contains an XY bar graph of some data you have.  This graph would,
  1191. of course, have the XY lines, the tick marks, the numbers for the tick
  1192. marks, the titles, the data bars, etc, all made up of a series of
  1193. QuickDraw calls, such as MoveTo, LineTo, FrameRect, PaintRect,
  1194. DrawString, etc.
  1195.  
  1196.  
  1197. - --- Setting up your application
  1198.  
  1199. All "imaging" for this window should happen ONLY in response to the
  1200. "update" event that is sent to this window.  Period.  Your update event
  1201. handler should look something like this...
  1202.  
  1203.   void DoUpdateEvent( WindowPtr  theWindow )
  1204.   {
  1205.      BeginUpdate( theWindow );
  1206.      DrawWindowContents( theWindow );
  1207.      EndUpdate( theWindow );
  1208.   }
  1209.  
  1210. The routine "DrawWindowContents" should draw EVERYTHING that appears in
  1211. your window whenever it is called regardless.  This is the correct thing
  1212. to do.  A window should always start life this way.  Do NOT put any calls
  1213. to draw this window anywhere else in your software.  No exceptions.
  1214.  
  1215. When the window is created, an update event will automatically be sent to
  1216. it. Convenient. 
  1217.  
  1218. And if there is some reason you need to update a certain area of your
  1219. window (and the system didn't ask you to), you can do this by
  1220. "invalidating" the desired area of your window, by calling InvalRect().
  1221. This triggers an update event to have that area of the window "cleaned
  1222. up".
  1223.  
  1224. In your update event handler, you must use the BeginUpdate and EndUpdate
  1225. calls, allowing you to take advantage of the Window Manager, which keeps
  1226. track of which part of your window actually needs to be re-drawn. ( The
  1227. update region ).
  1228.  
  1229. Your DrawWindowContents() routine will blindly draw everything to this
  1230. window, but the OS will automatically cut short any QuickDraw calls that
  1231. draw to areas of the window that do not actually need updating.
  1232.  
  1233. Even with this automatic built-in optimization, if you have a very
  1234. complex drawing, you will find that updating the window can be sluggish,
  1235. and you can see all the individual elements being re-drawn, as you do can
  1236. in, say, a complex MacDraw or Canvas drawing.
  1237.  
  1238. This is where GWorlds come in handy...
  1239.  
  1240.  
  1241. - --- Incremental Improvement #1
  1242.  
  1243. In response to the update event, create a GWorld the same size as your
  1244. window, draw the whole image into the GWorld instead, and then draw the
  1245. entire GWorld to the window all at once using CopyBits, then dispose of
  1246. the GWorld. 
  1247.  
  1248. This makes it so the user does not see all the individual elements being
  1249. redrawn.
  1250.  
  1251. This is what happens when you do a "lock screen" then an "unlock screen"
  1252. in HyperCard.
  1253.  
  1254. This does not, however, eliminate the time it takes to draw all the
  1255. individual elements. If you were to, say, move another window that
  1256. overlaps the bar graph window by just one pixel, an update event would,
  1257. of course, be sent to your bar graph window, and it would spend the time
  1258. redrawing the scores of things that make up the image.  To help optimize
  1259. that, we can take the usage of our GWorld a step further...
  1260.  
  1261.  
  1262. - --- Incremental Improvement #2
  1263.  
  1264. When you create your window for the first time, also create a GWorld the
  1265. same size as your window, and have DrawWindowContents() draw its image
  1266. into the GWorld instead, once only, to "prep" the GWorld.
  1267.  
  1268. Then from that point on, in response to an update event, simply use
  1269. CopyBits to transfer the ENTIRE GWorld to the entire window.  The Window
  1270. Manager will only allow the needed areas to actually be transferred, and
  1271. you will now have the most efficient and optimal way of handling the
  1272. imaging of window contents.
  1273.  
  1274. Your window updating will now be instantaneous, and there will be no
  1275. sluggishness.
  1276.  
  1277. When you close the window, dispose of the GWorld too.
  1278.  
  1279.  
  1280. - --- Important Note
  1281.  
  1282. This explanation is a lot like putting you in a row boat and giving you a
  1283. starting push in the direction of that little reef offshore you want to
  1284. get to.  
  1285.  
  1286. You do not need to know all about boats, all about the ocean, and all
  1287. about propulsion in order to make it to that little reef successfully. 
  1288. You also do not need to know at this time how to handle things
  1289. differently if you were hypothetically put in an outrigger instead.
  1290.  
  1291. Don't allow yourself or others to unnecessarily complicate things.  Take
  1292. this simple push and go with it, and you will quickly "get it".
  1293.  
  1294.  
  1295. - --- Following Advice
  1296.  
  1297. Mark my words.  If you put drawing-to-window code anywhere else than in
  1298. your update handler, you will find that a good chunk of your code, and
  1299. the time it took to develop it, ends up being spent on compensating for
  1300. the problems and side-effects that were created as a result of not
  1301. following this sage advice.
  1302.  
  1303. I made this mistake myself when I first started, and paid a hefty price
  1304. for it, too.  Hopefully you can avoid the waste of repeating this common
  1305. (and undocumented) programming error.
  1306.  
  1307.  
  1308. Hope this helps!
  1309.  
  1310. Mark Hanrek
  1311. The Information Workshop
  1312.  
  1313.  
  1314. - ----------------------------------
  1315.  
  1316. P.S.  The other undocumented programming error waiting to eat you is
  1317. mixing the use of GetPort/SetPort and GetGWorld/SetGWorld in the same
  1318. application.  
  1319.  
  1320. The minute you start working with GWorlds, eliminate all uses of
  1321. GetPort/SetPort from your application, changing them all to the more
  1322. modern GetGWorld/SetGWorld.
  1323.  
  1324. Ouch!
  1325.  
  1326. +++++++++++++++++++++++++++
  1327.  
  1328. >From kenlong@netcom.com (Ken Long)
  1329. Date: Tue, 5 Jul 1994 17:04:15 GMT
  1330. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1331.  
  1332. For more reading on GWorlds, get "Programming QuickDraw" by Surovell, 
  1333. Hall and Othmer.
  1334.  
  1335. For an example of an application comparison WITHOUT and WITH GWorlds 
  1336. (GWorld added by Mark Hanrek) get NuCube and NewCube C source demos. (I 
  1337. believe they are on sumex, in a file called "ThreePointPlotters" or 
  1338. "WireFrameORama").
  1339.  
  1340. There are excellent, comprehenhive examples of GWorld C sources on 
  1341. ftp.apple.com (GWorld Drawing - not an app. source, but several routines) 
  1342. and "GWorlds" from devtools.symantec.com - source for a complete application.
  1343.  
  1344. Of course, there are many more, too.  cicnAnimDemo uses GWorlds.
  1345.  
  1346. I was told, by a downloader of NuCude (which Mark contributed to), that 
  1347. he really gained a lot of understanding of them from the source.  Well, 
  1348. Mark understands them - that's why.
  1349.  
  1350. -Ken-
  1351.  
  1352. ---------------------------
  1353.  
  1354. >From brewster@enc.org (Dave Brewster)
  1355. Subject: Patching Trap ExitToShell using UniversalProcPtr's
  1356. Date: 5 Jul 1994 01:38:45 -0400
  1357. Organization: Eisenhower National Clearinghouse
  1358.  
  1359. How does one go about doing this on the PPC.  I've tried:
  1360.    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1361. where MyExitToShellUPP = 
  1362.    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1363. GetCurrentISA());
  1364.  
  1365. I figured this would be correct, but it dies a violent death!
  1366.  
  1367. Is the kCStackBased parameter wrong?  My routine doesn't take any
  1368. parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1369. return anything either.
  1370.  
  1371. My ExitToShell routine looks like:
  1372.  
  1373. void MyExitToShell (void)
  1374. {
  1375.    SetCurrentA5();
  1376.    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1377.    EndNNTP();
  1378.    NetTerm();
  1379.    ExitToShell();
  1380. }
  1381.  
  1382. What's the deal,
  1383.  
  1384. Dave
  1385.  
  1386. +++++++++++++++++++++++++++
  1387.  
  1388. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1389. Date: 5 Jul 1994 13:52:33 GMT
  1390. Organization: Microplex Pty Ltd
  1391.  
  1392. Dave Brewster (brewster@enc.org) wrote:
  1393. : How does one go about doing this on the PPC.  I've tried:
  1394. :    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1395. : where MyExitToShellUPP = 
  1396. :    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1397. : GetCurrentISA());
  1398.  
  1399. : I figured this would be correct, but it dies a violent death!
  1400.  
  1401. : Is the kCStackBased parameter wrong?  My routine doesn't take any
  1402. : parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1403. : return anything either.
  1404.  
  1405. : My ExitToShell routine looks like:
  1406.  
  1407. : void MyExitToShell (void)
  1408. : {
  1409. :    SetCurrentA5();
  1410. :    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1411. :    EndNNTP();
  1412. :    NetTerm();
  1413. :    ExitToShell();
  1414. : }
  1415.  
  1416. If you use the standard C library function "atexit" instead you would not 
  1417. have to worry about all this stuff.
  1418.  
  1419. In general, you should avoid patching traps. Most of the time it is 
  1420. not necessary.
  1421.  
  1422.  
  1423.  : What's the deal,
  1424.  
  1425. : Dave
  1426.  
  1427. Steve Coy
  1428. Resolve Software (WA) P/L
  1429.  
  1430.  
  1431. +++++++++++++++++++++++++++
  1432.  
  1433. >From wdh@netcom.com (Bill Hofmann)
  1434. Date: Tue, 5 Jul 1994 16:11:42 GMT
  1435. Organization: Fresh Software
  1436.  
  1437. In article <199407050538.FAA08919@charm.magnus.acs.ohio-state.edu>,
  1438. brewster@enc.org (Dave Brewster) wrote:
  1439.  
  1440. > How does one go about doing this on the PPC.  I've tried:
  1441. >    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1442. > where MyExitToShellUPP = 
  1443. >    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1444. > GetCurrentISA());
  1445. > I figured this would be correct, but it dies a violent death!
  1446. > Is the kCStackBased parameter wrong?  My routine doesn't take any
  1447. > parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1448. > return anything either.
  1449. > My ExitToShell routine looks like:
  1450. > void MyExitToShell (void)
  1451. > {
  1452. >    SetCurrentA5();
  1453. >    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1454. >    EndNNTP();
  1455. >    NetTerm();
  1456. >    ExitToShell();
  1457. > }
  1458. Well, with few exceptions, the entire toolbox is either kPascalStackBased
  1459. or kRegisterBased.  So you have two (well, 1.5) problems:
  1460.  
  1461. MyExitToShellUPP = NewRoutineDescriptor((ProcPtr)MyExitToShell,
  1462.                         kPascalStackBased, GetCurrentISA());
  1463. ...
  1464. pascal void MyExitToShell(void)
  1465. {
  1466. ...
  1467. }
  1468.  
  1469. I say 1.5 because a pascal void ... (void) is pretty much the same as a
  1470. void ... (void), but better to be compulsive than sorry.  I assume that
  1471. you init gOldExitToShellTrapAddress.  Does your code (minus the
  1472. NewRoutineDescriptor()) work on 040 machines?
  1473.  
  1474. -- 
  1475. Bill Hofmann                                   wdh@netcom.com
  1476. Fresh Software and Instructional Design        voice: +1 510 524 0852
  1477. 1640 San Pablo Ave #C, Berkeley CA 94702 USA   fax:   +1 510 524 0853
  1478.  
  1479. +++++++++++++++++++++++++++
  1480.  
  1481. >From kbell@cs.utexas.edu (Kevin Bell)
  1482. Date: Tue, 05 Jul 1994 18:34:35 -0600
  1483. Organization: The University of Texas at Austin, Austin, Texas
  1484.  
  1485. In article <199407050538.FAA08919@charm.magnus.acs.ohio-state.edu>,
  1486. brewster@enc.org (Dave Brewster) wrote:
  1487.  
  1488. > How does one go about doing this on the PPC.  I've tried:
  1489. >    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1490. > where MyExitToShellUPP = 
  1491. >    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1492. > GetCurrentISA());
  1493. > I figured this would be correct, but it dies a violent death!
  1494. > Is the kCStackBased parameter wrong?  My routine doesn't take any
  1495. > parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1496. > return anything either.
  1497. > My ExitToShell routine looks like:
  1498. > void MyExitToShell (void)
  1499. > {
  1500. >    SetCurrentA5();
  1501. >    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1502. >    EndNNTP();
  1503. >    NetTerm();
  1504. >    ExitToShell();
  1505. > }
  1506. > What's the deal,
  1507. > Dave
  1508.  
  1509. Here's the code I used to do the same thing
  1510.  
  1511. // KMB: ExitToShell UPP Info
  1512.  
  1513. static UniversalProcPtr gOldExitToShellTrapAddress;
  1514.  
  1515. enum {
  1516.     exitToShellProcInfo = kPascalStackBased
  1517. };
  1518.  
  1519. static void PatchExitToShell (void)
  1520. {
  1521.     UniversalProcPtr MyExitToShellUPP =
  1522.         NewRoutineDescriptor((ProcPtr)MyExitToShell,
  1523.                          exitToShellProcInfo,
  1524.                          GetCurrentISA());
  1525.     gOldExitToShellTrapAddress = GetToolTrapAddress(_ExitToShell);
  1526.     SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1527. }
  1528.  
  1529.  
  1530.     BTW, thanks for asking this question. When I tried to open the source
  1531. code with my PowerMac compiled NewsWatcher, I discovered some errors with
  1532. my standard file UPP stuff. IMHO, universal procedure pointers have a
  1533. serious problem in that the compiler cannot do any type checking like it
  1534. could for regular function pointers. In my case, I was creating a
  1535. FileFilterUPP where a ModalFilterUPP was needed.
  1536.  
  1537. -- 
  1538. Kevin Bell
  1539. kbell@cs.utexas.edu
  1540.  
  1541. ---------------------------
  1542.  
  1543. >From gtodorov@ralph.cs.haverford.edu (Gordan Todorovac)
  1544. Subject: Porting from Unix to Mac - Summary
  1545. Date: 1 Jul 1994 17:29:34 GMT
  1546. Organization: Haverford College Computer Science Department
  1547.  
  1548. Thanks to all who replied. Here is the content of three replies which summarize
  1549. what was said:
  1550.  
  1551.  
  1552. >From millsp@gov.on.ca Fri Jul  1 07:22:10 1994
  1553.  
  1554.   I haven't used version 5 for a year or more, but I'm quite sure that
  1555. malloc was available...#include <stdlib.h> and add the ANSI library to
  1556. your project certainly works in v6 and its not something new I've added
  1557. during the upgrade.
  1558.  
  1559.   If you're looking to move away from Unix-isms, there are Toolbox
  1560. calls, NewPtr and DisposPtr, for memory management.
  1561.  
  1562.   (I've done a few small ports of things that started on Unix.  My major
  1563. problems have been trying to understand library calls that don't exist
  1564. and don't seem to have matching concepts on the Mac...fork?
  1565. yfork?...but most of them should be there.)
  1566.  
  1567.  
  1568. >From gardner@osm7.cs.byu.edu Fri Jul  1 10:32:54 1994
  1569.  
  1570. I port code from the Unix to the Mac and from the Mac to Unix all the time 
  1571. (and to the PC in between).  The main thing to keep in mind is *not* to use
  1572. UNIXisms or MACisms (or PCisms).  If you program in strictly ANSI C, you
  1573. will 
  1574. not have a problem going either direction.  Now that does eliminate taking 
  1575. advantage of platform specific features.  But thats actually what
  1576. portability 
  1577. is all about.  
  1578.  
  1579. As for malloc, include stdlib.h for the prototype and add ANSI to your
  1580. project and you are all set.  Note:  THINK C gives you a set of unix-like
  1581. functions 
  1582. in unix.h that help you compile *some* code containing some UNIXisms. 
  1583. However, 
  1584. most do not implement the semantics/behavior of the unix function (mostly
  1585. because they have no MAC equivalent).  I would not use them except as a
  1586. last 
  1587. resort.
  1588.  
  1589.  
  1590. >From VCHAVARR@samnet.jsc.nasa.gov Fri Jul  1 11:27:52 1994
  1591.  
  1592. One of the biggest differences between Mac and Unix systems is the way the 
  1593. operating system allocates memory. Unix uses pointers, Macs use handles, 
  1594. which are pointers to pointers. The malloc function tells the Unix system to 
  1595. allocate a certain amount of memory and returns a pointer to it. Macs use a 
  1596. function called NewHandle to allocate a block of memory, and a handle is 
  1597. returned.
  1598.  
  1599. There is a Mac function called NewPtr (in the memory.h file, I believe), 
  1600. which allocates a block of memory and returns a pointer to it. Allocating 
  1601. memory on a Mac with pointers, however, can be a bad idea because memory 
  1602. segmentation can occur, especially if you are allocating a lot of memory. 
  1603. You could replace all of the mallocs in your code with NewPtr, if you're not 
  1604. worried about memory segmentation. This has the advantage of you not having 
  1605. to make changes to your code in the parts where pointers are referenced. If 
  1606. you use NewHandle to replace malloc, however, you will have to go and find 
  1607. all of the places where pointers are referenced and make some changes.
  1608.  
  1609. Another area of difference between Unix and Macs are in the functions which 
  1610. are used to handle files. You can expect problems in this area if your Unix 
  1611. program reads or writes files.
  1612.  
  1613. - -------------------------------
  1614. --Gordan
  1615.  
  1616.  
  1617. ---------------------------
  1618.  
  1619. >From rick@akbar.cc.utexas.edu (Rick Watson)
  1620. Subject: Problems with Metrowerks vs. MPW 68k C calling conventions
  1621. Date: 29 Jun 1994 18:43:25 GMT
  1622. Organization: The University of Texas at Austin, Austin, Texas
  1623.  
  1624. Metrowerks 68k C passes short values on the stack as 16-bit
  1625. values where MPW uses 32 bits. This causes problems when trying
  1626. to call MPW generated code modules, including MacTCP's 
  1627. domain resolver code called by DNR.c. 
  1628.  
  1629. Is there an easy workaround for this that does NOT involve prototyping
  1630. the short values as longs? 
  1631.  
  1632. Rick Watson 
  1633. The University of Texas Computation Center, Networking Services, 512/471-8220
  1634.  r.watson@utexas.edu
  1635.  
  1636. +++++++++++++++++++++++++++
  1637.  
  1638. >From edandavi@well.sf.ca.us (Ed Allen and Avi Rappoport)
  1639. Date: 29 Jun 1994 22:47:27 GMT
  1640. Organization: The Whole Earth 'Lectronic Link, Sausalito, CA
  1641.  
  1642. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1643.  
  1644. >Metrowerks 68k C passes short values on the stack as 16-bit
  1645. >values where MPW uses 32 bits. This causes problems when trying
  1646. >to call MPW generated code modules, including MacTCP's 
  1647. >domain resolver code called by DNR.c. 
  1648.  
  1649. >Is there an easy workaround for this that does NOT involve prototyping
  1650. >the short values as longs? 
  1651.  
  1652. Nope, there is no easy workaround.  Pascal libraries are fine, but C 
  1653. libraries have different parameter passing conventions, as you note 
  1654. above.  If you can get the source, compile it in MW.
  1655.  
  1656. Sorry.
  1657.  
  1658. -- 
  1659. Avi Rappoport                         (account also used by Ed Allen)
  1660. Systems Analyst and Technical Diplomat
  1661. metrowerks, Inc.
  1662. Please reply to: avirr@metrowerks.ca  avirr@aol.com  avirr@eworld.com
  1663.  
  1664. +++++++++++++++++++++++++++
  1665.  
  1666. >From mwron@aol.com (MW Ron)
  1667. Date: 29 Jun 1994 17:35:04 -0400
  1668. Organization: America Online, Inc. (1-800-827-6364)
  1669.  
  1670. In article <2usfcd$55p@geraldo.cc.utexas.edu>,
  1671. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1672.  
  1673. >>Metrowerks 68k C passes short values on the stack as 16-bit
  1674. values where MPW uses 32 bits.
  1675. Is there an easy workaround for this that does NOT involve
  1676. prototyping
  1677. the short values as longs? 
  1678.  
  1679. Did you change the structure allignment in your preferences Processor
  1680. for 4 byte int and 8 byte doubles,  and use the proper Libraries? I
  1681. am not an MPW user so if this isn't the fix, please reply.
  1682.  
  1683. Ron Liechty
  1684. mwron@aol.com
  1685. Metrowerks Inc.
  1686.  
  1687.  
  1688. +++++++++++++++++++++++++++
  1689.  
  1690. >From johnmce@world.std.com (John McEnerney)
  1691. Date: Thu, 30 Jun 1994 05:42:45 GMT
  1692. Organization: The World Public Access UNIX, Brookline, MA
  1693.  
  1694. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1695.  
  1696. >Metrowerks 68k C passes short values on the stack as 16-bit
  1697. >values where MPW uses 32 bits. This causes problems when trying
  1698. >to call MPW generated code modules, including MacTCP's 
  1699. >domain resolver code called by DNR.c. 
  1700.  
  1701. The problem is that although you may declare an argument 'short' or 
  1702. 'char' in MPW C, it will pass it as 32-bits. This was common in K&R 
  1703. compilers but is rare in ANSI compilers (THINK C does it the same way 
  1704. that we do)
  1705.  
  1706. The trick is to fool CW by declaring all integer arguments as 'long' in 
  1707. the prototype (including enums). Then the arguments will be properly 
  1708. extended to 32-bits.
  1709.  
  1710. -- John McEnerney, Metrowerks PowerPC Product Architect
  1711.  
  1712.  
  1713. +++++++++++++++++++++++++++
  1714.  
  1715. >From creiman@netcom.com (Charlie Reiman)
  1716. Date: Fri, 1 Jul 1994 05:36:05 GMT
  1717. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1718.  
  1719. mwron@aol.com (MW Ron) writes:
  1720.  
  1721. >In article <2usfcd$55p@geraldo.cc.utexas.edu>,
  1722. >rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1723.  
  1724. >>>Metrowerks 68k C passes short values on the stack as 16-bit
  1725. >values where MPW uses 32 bits.
  1726. >Is there an easy workaround for this that does NOT involve
  1727. >prototyping
  1728. >the short values as longs? 
  1729.  
  1730. >Did you change the structure allignment in your preferences Processor
  1731. >for 4 byte int and 8 byte doubles,  and use the proper Libraries? I
  1732. >am not an MPW user so if this isn't the fix, please reply.
  1733.  
  1734. >Ron Liechty
  1735. >mwron@aol.com
  1736. >Metrowerks Inc.
  1737.  
  1738. Think C has the exact same feature, even with 4 byte ints turned on.  I
  1739. did call up Symantec tech support and argue about this. I can no longer
  1740. quote the K&R ANSI page number, but the behavior you are seeing is not
  1741. incorrect.
  1742.  
  1743. It's stupid, but not incorrect. 
  1744.  
  1745. You need prototypes under Think, MW may have another solution.
  1746.  
  1747. -- 
  1748. "You can't cancel the project! We already made the T-shirts!"
  1749. Charlie Reiman
  1750. creiman@netcom.com
  1751.  
  1752. +++++++++++++++++++++++++++
  1753.  
  1754. >From StevenEllis@microapl.demon.co.uk (Steven Ellis)
  1755. Date: Thu, 30 Jun 1994 10:50:06 GMT
  1756. Organization: MicroAPL
  1757.  
  1758.  
  1759. In article <2usfcd$55p@geraldo.cc.utexas.edu> rick@akbar.cc.utexas.edu (Rick
  1760. Watson) writes:
  1761. >Metrowerks 68k C passes short values on the stack as 16-bit
  1762. >values where MPW uses 32 bits. This causes problems when trying
  1763. >to call MPW generated code modules, including MacTCP's 
  1764. >domain resolver code called by DNR.c. 
  1765. >
  1766. >Is there an easy workaround for this that does NOT involve prototyping
  1767. >the short values as longs? 
  1768.  
  1769. If you look in the compiler preferences there is an option to use 4byte short
  1770. values.
  1771.  
  1772. >
  1773. >Rick Watson 
  1774. >The University of Texas Computation Center, Networking Services, 512/471-8220
  1775. > r.watson@utexas.edu
  1776. >
  1777.  
  1778. Steven Ellis
  1779.  
  1780. +++++++++++++++++++++++++++
  1781.  
  1782. >From johnmce@world.std.com (John McEnerney)
  1783. Date: Fri, 1 Jul 1994 15:23:53 GMT
  1784. Organization: The World Public Access UNIX, Brookline, MA
  1785.  
  1786. creiman@netcom.com (Charlie Reiman) writes:
  1787.  
  1788. >>>>Metrowerks 68k C passes short values on the stack as 16-bit
  1789. >>values where MPW uses 32 bits.
  1790. >>Is there an easy workaround for this that does NOT involve
  1791. >>prototyping
  1792. >>the short values as longs? 
  1793.  
  1794. >Think C has the exact same feature, even with 4 byte ints turned on.  I
  1795. >did call up Symantec tech support and argue about this. I can no longer
  1796. >quote the K&R ANSI page number, but the behavior you are seeing is not
  1797. >incorrect.
  1798. >It's stupid, but not incorrect. 
  1799.  
  1800. Everybody thinks that they're a compiler designer...
  1801.  
  1802. The ANSI standard clarified that when an argument is declared 'float', 
  1803. 'char' or 'short' it does not have to be widened to 'double' or 'int' 
  1804. when passed as an argument. (The only exception is when there is no 
  1805. prototype or for arguments matching the "...") It also clarified that a 
  1806. compiler is not required to pass arguments in reverse order when the 
  1807. number of arguments in known.
  1808.  
  1809. This permits ANSI compilers to generate much better code, in this case 
  1810. avoiding an EXT.W for each argument passed. Some compilers (including 
  1811. Symantec C++ I think) will pass arguments in the order that they are 
  1812. declared and will have the calleee strip the arguments, again contrary to 
  1813. K&R practice, but also usually more efficient.
  1814.  
  1815. I don't see why every compiler for the Mac has to be saddled with the 
  1816. calling conventions of a compiler that Apple hasn't done any work on in 5 
  1817. years.
  1818.  
  1819. -- John McEnerney, Metrowerks PowerPC Product Architect
  1820.  
  1821. +++++++++++++++++++++++++++
  1822.  
  1823. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1824. Date: Fri, 1 Jul 1994 18:36:29 GMT
  1825. Organization: Apple Computer
  1826.  
  1827. Steven Ellis, StevenEllis@microapl.demon.co.uk writes:
  1828. > If you look in the compiler preferences there is an option to use 4byte
  1829. short
  1830. > values.
  1831.  
  1832. No, there is an option to use 4byte ints. shorts are always two bytes on
  1833. every Mac compiler (and on just about every other C compiler in the world,
  1834. with a few exceptions.) And shorts will always be pushed as 2 bytes by every
  1835. Mac compiler except MPW C.
  1836.  
  1837. I understand that Apple, Symantec and Metrowerks are hammering out a standard
  1838. C calling convention to be used by all their compilers, at least optionally
  1839. via pragmas. This becomes important with CFM and SOM on 68k, where C calling
  1840. conventions are used. (On PPC of course there is already one standard set of
  1841. calling conventions.)
  1842.  
  1843. --Jens Alfke
  1844.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1845.             .apple.com              Rebel girl you are the queen of my world
  1846.  
  1847. +++++++++++++++++++++++++++
  1848.  
  1849. >From creiman@netcom.com (Charlie Reiman)
  1850. Date: Sat, 2 Jul 1994 00:43:50 GMT
  1851. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1852.  
  1853. johnmce@world.std.com (John McEnerney) writes:
  1854.  
  1855. >creiman@netcom.com (Charlie Reiman) writes:
  1856.  
  1857. >>>>>Metrowerks 68k C passes short values on the stack as 16-bit
  1858. >>>values where MPW uses 32 bits.
  1859. >>>Is there an easy workaround for this that does NOT involve
  1860. >>>prototyping
  1861. >>>the short values as longs? 
  1862.  
  1863. >>Think C has the exact same feature, even with 4 byte ints turned on.  I
  1864. >>did call up Symantec tech support and argue about this. I can no longer
  1865. >>quote the K&R ANSI page number, but the behavior you are seeing is not
  1866. >>incorrect.
  1867. >>It's stupid, but not incorrect. 
  1868.  
  1869. >Everybody thinks that they're a compiler designer...
  1870.  
  1871. >The ANSI standard clarified that when an argument is declared 'float', 
  1872. >'char' or 'short' it does not have to be widened to 'double' or 'int' 
  1873. >when passed as an argument. (The only exception is when there is no 
  1874. >prototype or for arguments matching the "...") It also clarified that a 
  1875. >compiler is not required to pass arguments in reverse order when the 
  1876. >number of arguments in known.
  1877.  
  1878. >This permits ANSI compilers to generate much better code, in this case 
  1879. >avoiding an EXT.W for each argument passed. Some compilers (including 
  1880. >Symantec C++ I think) will pass arguments in the order that they are 
  1881. >declared and will have the calleee strip the arguments, again contrary to 
  1882. >K&R practice, but also usually more efficient.
  1883.  
  1884. >I don't see why every compiler for the Mac has to be saddled with the 
  1885. >calling conventions of a compiler that Apple hasn't done any work on in 5 
  1886. >years.
  1887.  
  1888. Don't get me wrong. I understand what you are trying to do. I just
  1889. think the anguish it causes developers isn't worth the win in compiler
  1890. speed. Calling it 'stupid' may have been harsh but you weren't here
  1891. when I had to debug the problem it caused. Nor were you here when I had
  1892. to wedgie protoypes on top of 300,000+ lines of complex cross-platform
  1893. code to avoid future problems.
  1894.  
  1895. I may not be a compiler designer, but I sure do beat the crap out of
  1896. them.  I know what breaks and I simply have to disagree with you.
  1897.  
  1898. -- 
  1899. "You can't cancel the project! We already made the T-shirts!"
  1900. Charlie Reiman
  1901. creiman@netcom.com
  1902.  
  1903. +++++++++++++++++++++++++++
  1904.  
  1905. >From Lars.Farm@nts.mh.se (Lars Farm)
  1906. Date: Sat, 02 Jul 1994 11:56:40 +0100
  1907. Organization: Mid Sweden University
  1908.  
  1909. In article <1994Jul1.183629.27436@gallant.apple.com>, Jens Alfke
  1910. <jens_alfke@powertalk.apple.com> wrote:
  1911.  
  1912. > I understand that Apple, Symantec and Metrowerks are hammering out a standard
  1913. > C calling convention to be used by all their compilers, at least optionally
  1914. > via pragmas. This becomes important with CFM and SOM on 68k, where C calling
  1915. > conventions are used. (On PPC of course there is already one standard set of
  1916. > calling conventions.)
  1917.  
  1918. Isn't this a place for extern "OtherCallingConvention" void foo(int);
  1919. as in extern "C", or extern "MPW", or extern "ASLM", or extern "SOM", or
  1920. extern "CFM", or extern "Pascal", ... leaving internal calling conventions
  1921. as an implementation detail to the specific compiler vendor?
  1922.  
  1923. Instead of #pragmas or worse - project wide preferences.
  1924.  
  1925. Lars
  1926.  
  1927. -- 
  1928. Lars.Farm@nts.mh.se
  1929.  
  1930. ---------------------------
  1931.  
  1932. >From dnebing@bgsu.edu (  Mr. Neb)
  1933. Subject: Special #define for Univ. Hdrs?
  1934. Date: 3 Jul 1994 04:16:21 GMT
  1935. Organization: Bowling Green State University
  1936.  
  1937.   Here's a quicky: I just got done adding Univ. Hdrs. to TC7.0.3
  1938. (headers from develop 18 CD) and started to recompile some existing
  1939. code to see if it would fly without any serious modifications.
  1940.  
  1941.   Everything was going fine until I recompiled a project that was using
  1942. IconFamilies.h (for those of you who don't remember, IconFamilies.h
  1943. was the file defined in TechNote #306, "Drawing Icons the System 7
  1944. Way").  Everything from IconFamilies.h has been shuffled into Icons.h.
  1945.  
  1946.   Hey, that's fine with me.  But I would like to modify my source to
  1947. include IconFamilies.h if the univ. hdrs. are not available.  Easiest
  1948. way to do this, I says to myself, is to surround the #include with
  1949. an #ifndef.  The only problem is that I don't know if there is a
  1950. constant defined so that I can distinguish between the old headers
  1951. and the universal headers.
  1952.  
  1953.   So to wrap up, is there a constant defined somewhere within the
  1954. universal headers?
  1955.  
  1956. ============================================================
  1957. Dave Nebinger                    dnebing@andy.bgsu.edu
  1958. Network Manager, Biology Dept.   dnebing@opie.bgsu.edu
  1959. Bowling Green State University   dnebing@bgsuopie (bitnet)
  1960. Bowling Green, OH 43403          #include <std_disclaimer.h>
  1961.  
  1962.              *THE* alt.sources.mac supporter!
  1963.  
  1964.  
  1965. +++++++++++++++++++++++++++
  1966.  
  1967. >From al@crucible.powertools.com (Al Evans)
  1968. Date: 4 Jul 94 14:31:12 GMT
  1969. Organization: PowerTools, Austin, Texas
  1970.  
  1971. In article <2v5e2l$rm@falcon.bgsu.edu> dnebing@bgsu.edu (  Mr. Neb) writes:
  1972.  
  1973. >  So to wrap up, is there a constant defined somewhere within the
  1974. >universal headers?
  1975.  
  1976. I've been using #ifdef __CONDITIONALMACROS__. As far as I can tell,
  1977. <ConditionalMacros.h> gets included any time you're using the
  1978. universal headers, but doesn't exist if you're not.
  1979.  
  1980.                     --Al Evans--
  1981. -- 
  1982. Al Evans            |   Graphic Elements: A new standard for 
  1983.                 |   high-performance interactive Macintosh graphics.
  1984. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  1985.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  1986.  
  1987. +++++++++++++++++++++++++++
  1988.  
  1989. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  1990. Date: Mon, 04 Jul 1994 10:32:51 +0800
  1991. Organization: NCRPDA, Curtin University
  1992.  
  1993. In article <2v5e2l$rm@falcon.bgsu.edu>, dnebing@bgsu.edu (  Mr. Neb) wrote:
  1994.  
  1995. >  Hey, that's fine with me.  But I would like to modify my source to
  1996. >include IconFamilies.h if the univ. hdrs. are not available.  Easiest
  1997. >way to do this, I says to myself, is to surround the #include with
  1998. >an #ifndef.  The only problem is that I don't know if there is a
  1999. >constant defined so that I can distinguish between the old headers
  2000. >and the universal headers.
  2001.  
  2002. Wow, another few years and this will be almost as much fun as trying to
  2003. get a unix program compiled.
  2004.  
  2005. I just love the C #define, #include method of seperate compilation. 
  2006. Brilian piece of design :-)
  2007.    Peter.
  2008. _______________________________________________________________________
  2009. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  2010.  
  2011. ---------------------------
  2012.  
  2013. >From mdtaylor@apple.com (Mark D. Taylor)
  2014. Subject: Why does THINK C use a jump table?
  2015. Date: 17 Jun 1994 10:08:53 -0700
  2016. Organization: Apple Computer Inc, Cupertino, CA
  2017.  
  2018. Or more specifically, why does a call of a function in the same source file
  2019. and segment of the caller go through a jump table?
  2020.  
  2021. I'm having a problem with this because the call occurs at interrupt time
  2022. when A5 is not guaranteed and sometimes the jump table is not where the code
  2023. thinks it should be.
  2024.  
  2025. So what controls whether the jump table is used?  How can I disable it?
  2026.  
  2027. Thanks,
  2028. Mark
  2029.  
  2030.  
  2031. +++++++++++++++++++++++++++
  2032.  
  2033. >From doc@miracle.farallon.com (eric doc kampman)
  2034. Date: Fri, 17 Jun 1994 18:17:52 -0800
  2035. Organization: farallon
  2036.  
  2037. In article <2tslb5$d6c@apple.com>, mdtaylor@apple.com (Mark D. Taylor)
  2038. wrote:
  2039.  
  2040. > Or more specifically, why does a call of a function in the same source file
  2041. > and segment of the caller go through a jump table?
  2042. > I'm having a problem with this because the call occurs at interrupt time
  2043. > when A5 is not guaranteed and sometimes the jump table is not where the code
  2044. > thinks it should be.
  2045. > So what controls whether the jump table is used?  How can I disable it?
  2046.  
  2047. Short answer -- as far as I can tell, when one routine calls another it
  2048. *always* goes through the jump table -- even if the routine you're calling
  2049. is defined in the same source file and is 2 bytes away from the PC.  This
  2050. "feature" has caused me to retreat back to MPW when I'm not doing OOP
  2051. stuff.  You're going to have to save your A5 somewhere you can retrieve it
  2052. when you're not the front app.  There are many different situations where
  2053. this occurs and many ways of handling it.  For a generic solution -- check
  2054. out <SetUpA4.h> (in THINK #includes) for a *very* interesting way of saving
  2055. register values where you can get to them. It takes a little while to see
  2056. why what they're doing works (or at least it did for me).
  2057.  
  2058. -- 
  2059. doc@miracle.farallon.com
  2060. Farallon didn't write this, Farallon isn't responsible for its con-
  2061. tents -- Farallon is an abstract class and cannot be held responsible
  2062. for the quality of instantiations of derived classes.  
  2063. ********************************************************************
  2064.  Look for the thing you can't find/Seeing with eyes makes you blind
  2065.                You know you're out of your mind 
  2066.  
  2067. +++++++++++++++++++++++++++
  2068.  
  2069. >From siegel@netcom.com (Rich Siegel)
  2070. Date: Sat, 18 Jun 1994 01:20:21 GMT
  2071. Organization: Bare Bones Software
  2072.  
  2073. In article <2tslb5$d6c@apple.com> mdtaylor@apple.com (Mark D. Taylor) writes:
  2074. >Or more specifically, why does a call of a function in the same source file
  2075. >and segment of the caller go through a jump table?
  2076.  
  2077. (one of) Two reasons: it's not declared 'static', and/or you take its
  2078. address at some point in the code. If it's not declared static, it
  2079. needs to be accessible through the jump table so that other functions
  2080. can call it. If you take its address, it has to be indirected thruogh
  2081. the jump table to ensure position independence.
  2082.  
  2083. R.
  2084.  
  2085.  
  2086.  
  2087. -- 
  2088. Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software
  2089. --> For information about BBEdit, finger bbedit@world.std.com <--
  2090.  
  2091. "...yeah, I inhaled, and then I drank the bong water. So what're
  2092. you gonna do about it?" - Dennis Miller, on Bill Clinton
  2093.  
  2094. +++++++++++++++++++++++++++
  2095.  
  2096. >From gurgle@netcom.com (Pete Gontier)
  2097. Date: Sat, 18 Jun 1994 05:00:40 GMT
  2098. Organization: cellular
  2099.  
  2100. mdtaylor@apple.com (Mark D. Taylor) writes:
  2101.  
  2102. >Or more specifically, why does a call of a function in the same source
  2103. >file and segment of the caller go through a jump table? I'm having a
  2104. >problem with this because the call occurs at interrupt time when A5
  2105. >is not guaranteed and sometimes the jump table is not where the code
  2106. >thinks it should be. So what controls whether the jump table is used?
  2107. >How can I disable it?
  2108.  
  2109. You can't disable it without using another compiler, but you can make
  2110. sure your interrupt code works. First make sure the segment in question
  2111. is loaded by doing some work at non-interrupt time. Make a call into
  2112. the segment, perhaps to a dummy routine which exists solely to force
  2113. the segment to load. Make sure you don't subsequently call UnloadSeg
  2114. for that segment. Then, in your interrupt code, make sure A5 is set up
  2115. properly before you make the interrupt-time call into the segment. I
  2116. believe you will find relevant documentation in the usual places under
  2117. 'SetCurrentA5'.
  2118.  
  2119. None of this stuff is relevant under PowerPC, of course.
  2120. -- 
  2121.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2122.  
  2123.  'It seems the firm contracted by Intel to produce the famed "flying
  2124.  Pentium" ads could not complete the 3-D modeling on a PC before
  2125.  deadline. So in the best know-your-enemy tradition, they chose the next
  2126.  best thing -- a Quadra 840AV.'                 -- Mac The Knife 4/18/94
  2127.  
  2128. +++++++++++++++++++++++++++
  2129.  
  2130. >From gurgle@netcom.com (Pete Gontier)
  2131. Date: Sat, 18 Jun 1994 17:26:11 GMT
  2132. Organization: cellular
  2133.  
  2134. mdtaylor@apple.com (Mark D. Taylor) writes:
  2135.  
  2136. >Or more specifically, why does a call of a function in the same source
  2137. >file and segment of the caller go through a jump table?
  2138.  
  2139. Rich posted the reasons why, and I posted a way for you to make your
  2140. interrupt code work. But I don't think anybody yet has specifically
  2141. talked about the general case of how to make jump table entries go away.
  2142. If your routine is declared 'static' and you don't take its address,
  2143. *that* will guarantee it will not generate a jump table entry. (If your
  2144. routine is only referenced from its own segment, it will not generate a
  2145. jump table entry when building a stand-alone app, but it's more common
  2146. for programmers to want to run their app from TPM.)
  2147.  
  2148. This gives me an opportunity to be even a little more pedantic.
  2149.  
  2150. THINK C supports a language extension "require prototypes". Most people
  2151. should have it turned on (in the project settings dialog), because it
  2152. only helps you build safer and stronger software at the expense of some
  2153. extra typing sometimes. But most people don't know how to take advantage
  2154. of it. They turn it on, and the compiler encounters a function like
  2155. 'foo':
  2156.  
  2157.     void foo (void) { }
  2158.     void main (void) { foo ( ); }
  2159.  
  2160. ...and of course the compiler complains because there is no prototype
  2161. for 'foo' in scope. People's response is generally to give the compiler
  2162. a prototype, even for routines which will never be called from another
  2163. module:
  2164.  
  2165.     void foo (void);
  2166.         void foo (void) { }
  2167.         void main (void) { foo ( ); }
  2168.  
  2169. ...and this makes the compiler shut up. But there is a much better way:
  2170.  
  2171.     static void foo (void) { }
  2172.         void main (void) { foo ( ); }
  2173.  
  2174. ...this not only makes the compiler shut up, but it prevents 'foo'
  2175. from requiring a jump table entry, as long as you don't also take its
  2176. address. This not only keeps your jump-table less crowded, but it also
  2177. relieves you of having to deal with the possibility that A5 (or A4 in
  2178. some cases) is not valid when 'foo' is called. (If 'foo' is going to
  2179. call other routines which rely on A5 (or A4), 'foo' still needs to make
  2180. sure A5 (or A4) is valied before calling those other routines.)
  2181.  
  2182. Now, some people will say that relying on this behavior is a bad idea,
  2183. because the ANSI standard doesn't specify that 'static' should have
  2184. this effect. However, neither does the ANSI standard specify that a
  2185. feature like "require prototypes" be supported. When you hit the "ANSI
  2186. settings" button in the prefs dialog, notice that "infer prototypes"
  2187. gets selected, not "require prototypes". So since "require prototypes"
  2188. isn't ANSI in the first place, you might as well rely on the 'static'
  2189. keyword to help you use "require prototypes". I know CodeWarrior
  2190. supports it, by the way, and I suspect MPW C supports it in some similar
  2191. fashion, as well.
  2192.  
  2193. The reason I really like to use the 'static' keyword in this way is the
  2194. way THINK C segmentation works. You can only control segmentation at the
  2195. module level, so by definition 'static' routines cannot be called from
  2196. another segment. The linker simply won't cooperate. Using the 'static'
  2197. keyword in this way can prevent a whole layer of mistakes before they
  2198. require debugging time.
  2199. -- 
  2200.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2201.  
  2202.  You thought Obfuscated C was confusing? Wait for Obfuscated C++!
  2203.  
  2204. +++++++++++++++++++++++++++
  2205.  
  2206. >From ari@world.std.com (Ari I Halberstadt)
  2207. Date: Mon, 20 Jun 1994 04:47:12 GMT
  2208. Organization: The World Public Access UNIX, Brookline, MA
  2209.  
  2210. In article <gurgleCrLsFo.3Hy@netcom.com>,
  2211. Pete Gontier <gurgle@netcom.com> wrote:
  2212. >...
  2213. >The reason I really like to use the 'static' keyword in this way is the
  2214. >way THINK C segmentation works. You can only control segmentation at the
  2215. >module level, so by definition 'static' routines cannot be called from
  2216. >another segment. The linker simply won't cooperate. Using the 'static'
  2217. >keyword in this way can prevent a whole layer of mistakes before they
  2218. >require debugging time.
  2219.  
  2220. There's another good reason to use this feature. It saves you from
  2221. having to put prototypes into the file, which means a bit less work
  2222. for the programmer/maintainer. It also helps give some logical
  2223. structure to your source files, since static functions need to be
  2224. defined before you can use them. If you really need to use a function
  2225. before it's defined, you can place a prototype for that function near
  2226. the head of the source file.
  2227. -- 
  2228. Ari Halberstadt                                 ari@world.std.com
  2229. One generation passes away, and another generation comes: but the
  2230. earth abides for ever. -- Ecclesiastes, 1:4.
  2231.  
  2232. +++++++++++++++++++++++++++
  2233.  
  2234. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  2235. Date: Fri,  1 Jul 1994 09:12:14 -0400
  2236. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  2237.  
  2238. There are two ways around think c using A5 to make calls:
  2239.  
  2240. a) have an lea instruction at the start of the routine (use asm {}) and
  2241. patch it before using the address at interrupt time.  (then flush the
  2242. code caches)
  2243.  
  2244. b) Compile the code in question as a code resource and load the resource.
  2245.  
  2246. See the code samples on akutaktak.andrew.cmu.edu [128.2.35.1] in the
  2247. /aw0g directory for some examples of using code resources.
  2248.  
  2249.  
  2250. ---------------------------
  2251.  
  2252. End of C.S.M.P. Digest
  2253. **********************
  2254.  
  2255.  
  2256.  
  2257.